package com.example.demo.service;

import com.example.demo.dao.UserDao;
import com.example.demo.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.Optional;

@CacheConfig
@Service
public class UserService {
    @Autowired
    UserDao userDao;

//    @Cacheable(cacheNames = "user")
    public User getUserById(String userId) {
        Optional<User> users =  userDao.findById(userId);
        return users.orElse(null);
    }

    public User updateUserById(String email,String userId) {
        int a =  userDao.updateUserByUserId(email,userId);
        System.out.println(a);
        return getUserById(userId);
    }
}
